<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="zh">
<!--<![endif]-->
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>

<head>
    <meta charset="utf-8"/>
    <title>保险代理后台管理系统</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>
    <meta content="" name="description"/>
    <meta content="" name="author"/>
    <!-- ================== BEGIN BASE CSS STYLE ================== -->
    <jsp:include page="../common/header.jsp"></jsp:include>
    <%@include file="../common/taglib.jsp" %>
    <!-- ================== END BASE CSS STYLE ================== -->

    <!-- ================== 单独作用于本页表格td ================== -->
    <style>
        body {
            background: white;
        }

        .form-control {
            width: 200px;
        }

        .control-label {
            width: 130px;
        }    </style>
    <!-- ================== 单独作用于本页表格td ================== -->

</head>
<body>
<section class="pad-top-10 pad-bottom-20">
    <ul class="nav nav-pills">
        <li><a href="#tab1" data-toggle="tab">投保客户信息</a></li>
        <li><a href="#tab6" data-toggle="tab">保险信息</a></li>
        <li><a href="#tab7" data-toggle="tab">费用合计</a></li>
        <li><a href="#tab4" data-toggle="tab">财务支付信息</a></li>
        <li class="active"><a href="#tab5" data-toggle="tab">完善保单信息</a></li>
    </ul>
    <div <%--class="panel-body"--%>>
        <div class="table-responsive">
            <div class="form-wrap mar-bottom-0">
                <div class="tab-content">

                    <!-- 投保客户信息 -->
                    <div id="tab1" class="tab-pane fade">
                        <form class="form-horizontal form-bordered">
                            <section>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">保单号:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.ordNum }</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">车主:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.carOwner }</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">车牌号:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.plateNum }</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">车架号:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.frameNumber }</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">车辆种类:</label>
                                    <div class="col-md-2">
                                        <c:if test="${order.vehicleType==1 }">
                                            <p class="form-control-static">客车</p>
                                        </c:if>
                                        <c:if test="${order.vehicleType==2 }">
                                            <p class="form-control-static">货车</p>
                                        </c:if>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">被保险人:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.insurant }</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">被保险人身份证号/组织机构代码:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.orgIdCode }</p>
                                    </div>
                                </div>
                            </section>
                        </form>
                    </div>


                    <!-- 保险信息 -->
                    <div id="tab6" class="tab-pane fade">
                        <form class="form-horizontal form-bordered">
                            <section>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">保险公司:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.insyrerName }</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">险种:</label>
                                    <div class="col-md-2">
                                        <c:choose>
                                            <c:when test="${order.typeInsurance==0 }">
                                                <p class="form-control-static">交强险</p>
                                            </c:when>
                                            <c:otherwise>
                                                <p class="form-control-static">商业险</p>
                                            </c:otherwise>
                                        </c:choose>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">保单生效日期:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.dateIssuance }</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">垫资类型:</label>
                                    <div class="col-md-2">
                                        <c:if test="${order.typeInsurance2==1 }">
                                            <p class="form-control-static">不垫资</p>
                                        </c:if>
                                        <c:if test="${order.typeInsurance2==2 }">
                                            <p class="form-control-static">垫返点</p>
                                        </c:if>
                                        <c:if test="${order.typeInsurance2==3 }">
                                            <p class="form-control-static">垫保费</p>
                                        </c:if>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">垫资账期:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.laonAccount }天</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">保险费:</label>
                                    <div class="col-md-2">
                                        <c:choose>
                                            <c:when test="${order.typeInsurance==0 }">
                                                <p class="form-control-static">${order.pulsoryPremium }元</p>
                                            </c:when>
                                            <c:otherwise>
                                                <p class="form-control-static">${order.mercialPremium }元</p>
                                            </c:otherwise>
                                        </c:choose>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">保险公司返点:</label>
                                    <div class="col-md-2">
                                      <c:if test="${order.typeInsurance==0 }">
                                        <p class="form-control-static">交强险跟单点位:${order.followPoint }%</p>
                                        <p class="form-control-static">交强险补单点位:${order.replenishPoint }%</p>
                                      </c:if>
                                      <c:otherwise>
                                      	<p class="form-control-static">商业险跟单点位:${order.followPoint }%</p>
                                        <p class="form-control-static">商业险补单点位:${order.replenishPoint }%</p>
                                      </c:otherwise>
                                    </div>
                                </div>
                            </section>
                        </form>
                    </div>


                    <!-- 费用合计 -->
                    <div id="tab7" class="tab-pane fade">
                        <form class="form-horizontal form-bordered">
                            <section>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">全保费:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.allPremium }元</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">渠道应支付保费合计:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${channelRecord.mustPremium }元</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">保险公司跟单手续费:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${companyRecord.followRpoundage }元</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">保险公司补点手续费:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${companyRecord.replenishRpoundage }元</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">税后保费:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.texPremium }元</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">渠道返点:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${order.channelRebate }%</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">渠道返佣费合计:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${channelRecord.realRebateAmt }元</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">付款主体:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">
                                            <c:if test="${order.paySubject==1 }">
                                                环宇康泰
                                            </c:if>
                                            <c:if test="${order.paySubject==2 }">
                                                青岛盛达
                                            </c:if>
                                            <c:if test="${order.paySubject==3 }">
                                                玉环天云
                                            </c:if>
                                            <c:if test="${order.paySubject==4 }">
                                                汉龙
                                            </c:if>
                                        </p>
                                    </div>
                                </div>
                            </section>
                        </form>
                    </div>


                    <!-- 财务支付信息 -->
                    <div id="tab4" class="tab-pane fade">
                        <form class="form-horizontal form-bordered">
                            <section>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">收渠道金额:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${channelRecord.mustPremium }</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">收款日期:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${channelRecord.receiptDate }</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">收款凭证:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static"><a onclick="fileOpen('${attachment.url}')">${attachment.name}</a></p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">付保险公司金额:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${companyRecord.mustPremium }元</p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-md-1 control-label">付保险公司日期:</label>
                                    <div class="col-md-2">
                                        <p class="form-control-static">${companyRecord.receiptDate }</p>
                                    </div>
                                </div>
                            </section>
                        </form>
                    </div>


                    <!-- 完善保单信息 -->
                    <div id="tab5" class="tab-pane fade active in">
                        <form class="form-horizontal form-bordered" id="form" method="post"
                              data-parsley-validate="true">
                            <input type="hidden" value="${order.typeInsurance2 }" name="typeInsurance2">
                            <input type="hidden" value="${ordCode }" name="ordCode">
                            <input type="hidden" value="${order.tid }" name="tid">
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">保单号:</label>
                                <div class="col-md-6 col-sm-6">
                                    <input type="hidden" value="${insurer.policyNumber }" id="Innumber">
                                    <input type="text" value="${insurer.policyNumber }" id="ordNum" class="form-control"
                                           name="ordNum" data-parsley-inlength="true"
                                           data-parsley-inlength-message="请输入正确保单号" data-parsley-required="true"
                                           data-parsley-required-message="保单号不能为空" data-parsley-only="true"
                                           data-parsley-only-message="该保单号已被使用">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-1 control-label">出单员:</label>
                                <div class="col-md-2">
                                    <select style="list-style-type: none;" class="form-control" name="saleman"
                                            data-parsley-required="true" data-parsley-required-message="出单员不能为空">
                                        <option value="">请选择</option>
                                        <c:forEach items="${userList }" var="user">
                                            <option value="${user.tid }">${user.username }</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">出单日期:</label>
                                <div class="col-md-6 col-sm-6">
                                    <input type="text" id="dateIssuance" name="dateIssuance"
                                           class="form-control selectData" data-parsley-required="true"
                                           data-parsley-required-message="出单日期不能为空">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">保单生效日期:</label>
                                <div class="col-md-6 col-sm-6">
                                    <input type="text" onchange="updateTime()" id="datePolicy"
                                           value="${order.insureStartDate }" name="datePolicy"
                                           class="form-control selectData" data-parsley-required="true"
                                           data-parsley-required-message="保单生效日期不能为空">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">保单失效日期:</label>
                                <div class="col-md-6 col-sm-6">
                                    <input type="text" value="${order.insureEndDate }" id="expireDate" name="expireDate"
                                           class="form-control selectData" data-parsley-required="true"
                                           data-parsley-required-message="保单失效日期不能为空">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-md-4 col-sm-4">&nbsp;</label>
                                <div class="col-md-6 col-sm-6">
                                    <button type="button" id="showTab" class="btn btn-primary m-r-10">&nbsp;提交&nbsp;
                                    </button>
                                    <a onclick="getParent()" class="btn btn-default"
                                       data-toggle='modal'>&nbsp;取消&nbsp;</a>
                                </div>
                            </div>
                        </form>
                    </div>

                </div>
            </div>
        </div>
    </div>
</section>
<table class="bg-warning">
    <thead>
    <tr>
        <th>操作记录</th>
        <th>操作人</th>
        <th>操作时间</th>
        <th>备注</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${optionList}" var="opt">
        <tr>
            <td>${opt.content}</td>
            <td>${opt.createUser.roleName}(${opt.createUser.realName})</td>
            <td><javatime:format value="${opt.createAt}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
            <td>${opt.remark}</td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<jsp:include page="../common/footer.jsp"/>
<script src="${ctx}/static/js/order/main_order.js"></script>
<script src="${ctx}/static/js/order/pay_order_list.js"></script>
</body>
<script>
    $(document).ready(function () {
        App.init();
        TableManageFixedHeader.init();
    });

    function getParent() {
        $("#modal-dialog2", window.parent.document).modal().show();
    }

    window.ParsleyValidator.addValidator('inlength', function (value) {
        if (value != "") {
            var Innumber = $("#Innumber").val();
            console.log(Innumber.length);
            return value.length > Innumber.length;
        }
        return true;
    }, 32);

    function updateTime() {
        var datePolicy = $("#datePolicy").val();
        var datePolicyNum = new Date(datePolicy).getTime();
        var expireDateNum = datePolicyNum + 365 * 24 * 60 * 60 * 1000;
        var expireDate = new Date(expireDateNum);
        var expireDate1 = dateFtt("yyyy-MM-dd", expireDate);
        $("#expireDate").val(expireDate1);
    }

    $("#showTab").click(function () {
        $('#form').parsley().whenValidate({}).done(function () {
            $.ajax({
                type: "post",
                url: "/ins/order/updateByOrdCode",
                data: $("#form").serialize(),
                success: function (msg) {
                    if (msg.success == true) {
                        window.parent.location.href = "<%=path%>/ins/order/skipOrderList";
                    }
                }
            });
        });
    });

    window.ParsleyValidator.addValidator('only', function (ordNum) {
        var result = true;
        if (ordNum != "" && ordNum != null) {
            $.ajax({
                type: "post",
                url: "/ins/order/onlyOrdNum",
                async: false,
                data: {ordNum: ordNum},
                success: function (msg) {
                    if (msg.success != true) {
                        result = false;
                    }
                }
            });
        }
        return result;
    }, 32);
    window.onload=function(){
        var s = parent.document.getElementById('iframeParent');
        var $tabPane=$('.tab-pane');

        function setIframeHeight(){
            s.style.height =document.body.offsetHeight+'px';
        }

        setIframeHeight();

        $(".nav").find("li").click(function (){
            var $index=$(this).index();
            $tabPane.eq($index).addClass('aa')
            setTimeout(function (){
                if($tabPane.eq($index).hasClass('active')){
                    setIframeHeight();
                }
            },200);
        });
    }
    function fileOpen(url) {
        window.open(url);
    }
</script>
</html>